docs: Make example run smoothly by catching exception#482
Conversation
`g.delete()` raises exception if the graph does not exist. Having such an example on the front page is not very welcoming. Catching the exception and sweeping under the carpet solves this. Reported as FalkorDB#481
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR updates the Python "Getting Started" example to wrap ChangesPython Getting Started Example
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
index.md (1)
77-81: ⚡ Quick winNarrow the exception handling to avoid masking real failures.
This catches all runtime errors, so unrelated issues can be silently ignored. Handle only the expected “graph missing” case and re-raise everything else.
Proposed change
try: g.delete() -except Exception: - # Graph doesn't exist yet, which is fine - pass +except Exception as e: + # Ignore only the expected "graph does not exist" case. + if "does not exist" in str(e).lower(): + pass + else: + raise🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@index.md` around lines 77 - 81, The current try/except around g.delete() swallows all exceptions; narrow it to only ignore the expected "graph missing" error and re-raise all others. Replace the bare except with either a catch of the specific error class thrown when the graph does not exist (e.g., GraphNotFoundError, KeyError, or FileNotFoundError depending on the graph implementation) or use "except Exception as e:" and inspect e (error type or message) to only pass for the missing-graph case and raise for anything else; reference the g.delete() call and variable g when making this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@index.md`:
- Around line 77-81: The current try/except around g.delete() swallows all
exceptions; narrow it to only ignore the expected "graph missing" error and
re-raise all others. Replace the bare except with either a catch of the specific
error class thrown when the graph does not exist (e.g., GraphNotFoundError,
KeyError, or FileNotFoundError depending on the graph implementation) or use
"except Exception as e:" and inspect e (error type or message) to only pass for
the missing-graph case and raise for anything else; reference the g.delete()
call and variable g when making this change.
g.delete()raises exception if the graph does not exist.Having such an example on the front page is not very welcoming. Catching the exception and sweeping under the carpet solves this.
Reported as #481
Summary by CodeRabbit